#!/bin/sh

sed '/""/d;s/ \[est\.\]//g;s/"\$\([0-9,]*\)"/"\1"/g;s/\([0-9]\),\([0-9]\)/\1\2/g;s/^"\(.*\)"$/\1/g' movie-final-2 |\
awk 'BEGIN { FS = "\",\""; OFS = "\",\"" } { r = ""; split("Action,Adventure,Animation,Biography,Comedy,Crime,Documentary,Drama,Family,Fantasy,History,Horror,Music,Musical,Mystery,Romance,Sci-Fi,Short,Sport,Thriller,War,Western", name, ","); for (n in name) { genres[name[n]] = 0 } split($7, arr, ", "); for (i in arr) { genres[arr[i]] = 1 } for (g in genres) { r = r""genres[g]"," } $7 = r; print }' |\
awk 'BEGIN { FS = "\",\""; OFS = "," } { split($4, date, " "); $4 = date[1]; for (i = 3; i <= NF; i++) { split($i, arr, ", "); $i = arr[1] } $13 = int($15 / $14 * $13); print }' |\
sed 's/,,/,/g;s/, /_/g;s/ /_/g'
